﻿using Brc_PaaS.Bll.Account;
using Brc_PaaS.Common.Model.Account;
using Brc_PaaS.Common.Model.Basic;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;

namespace Brc_PaaS.Api.PaaSController
{
    [Route("PaaS/[controller]/[action]")]
    [ApiController]
    [EnableCors("any")]
    [ApiExplorerSettings(GroupName = "PaaSBasic")]
    public class PaaSAccountController : ControllerBase
    {
        private readonly IAccount accountService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="accountService"></param>
        public PaaSAccountController(IAccount accountService)
        {
            this.accountService = accountService;
        }

        /// <summary>
        /// 注册账户
        /// </summary>
        /// <param name="registerAccountDto"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult<ResponseModel<string>> RegisterAccount([FromBody]RegisterAccountDto registerAccountDto)
        {
            var result = accountService.RegisterAccount(registerAccountDto);
            return Ok(result);
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="loginCredentialDto"></param>
        /// <returns></returns>
        [HttpPost]
        
        public ActionResult<ResponseModel<string>> Login([FromBody]LoginCredentialDto loginCredentialDto)
        {
            var result = accountService.Login(loginCredentialDto);
            return Ok(result);
        }

    }
}